package JoReg

type Symbol struct {
	symVal         int
	productionSlcs [][]int
	firstSet       []int
	followSet      []int
	selectionSet   [][]int
	isNullable     bool
}

func MakeSymbol(symVal int, productionSlc [][]int, nullable bool) *Symbol {
	symbolPtr := &Symbol{
		symVal:         symVal,
		productionSlcs: productionSlc,
		isNullable:     nullable,
		firstSet:       make([]int, 0),
		followSet:      make([]int, 0),
		selectionSet:   make([][]int, 0),
	}
	if symVal < 256 {
		symbolPtr.firstSet = append(symbolPtr.firstSet, symVal)
	}
	return symbolPtr
}

func (this *Symbol) addFollowSet(firstSet []int, tablePtr *TableBuild) {
	for _, first := range firstSet {
		if isContainer(this.followSet, first) == false {
			this.followSet = append(this.followSet, first)
			tablePtr.runFollowSetFlag = true
		}
	}
}
